<?php
/**
 * TinyMVC - TinyMVCResource.class.php file
 *
 * @author Adrian Wieczorek <adi(at)tinymvc(dot)org>
 * @package TinyMVC
 * @version $Id: TinyMVCResource.class.php 57 2008-11-07 08:43:14Z adi3ek $
 *
 */

/**
 * Framework resources container class
 * 
 * It may contain any of the folowing:
 * 
	* - "includable" php files (classes, interfaces... simply put: php code) or just folders?
	* - files or directories (e.g. view templates)
	* - objects (e.g. wrappers, etc.)
	* - http accessible files (css files, images, etc.)
	* 
 * @package TinyMVC
 */
class TinyMVCResource {
	protected $name;
	protected $container;

	public function __construct($name) {
		$this->name = $name;
		$this->container = new TinyMVCSimpleContainer;
	}

	public function getName() {
		return $this->name;
	}

	public function get($name) {
		return $this->container->getElement($name);
	}

	public function __get($name) {
		return $this->get($name);
	}

	public function getElement($name) {
		return $this->get($name);
	}

	public function getElements() {
		return $this->container->getElements();
	}

	public function set($key, $value) {
		$this->addElement($key, $value);
	}

	public function __set($key, $value) {
		$this->addElement($key, $value);
	}

	public function add($key, $value) {
		$this->addElement($key, $value);
	}

	public function addElement($key, $value) {
		$this->container->addElement($key, $value);
	}
	
	public function isKeyExists($key) {
		return $this->container->isKeyExists($key);
	}
	
	public function __isset($key) {
		return $this->isKeyExists($key);
	}

}
